//test to see if the mouse is on any menu.
MouseClicked();
IsMouseOnMenu1();
IsMouseOnMenu2();
IsMouseOnMenu3();
//if mouse is not on any menus and is not on the top text box, 
//then close all the menus. Note: mouseOnBox is found in the 
//button action script.
if (!(mouseOnBox||mouseOnMenu1||mouseOnMenu2||mouseOnMenu3)){
	CloseMenu3();
	CloseMenu2();
	CloseMenu1();
}
//if the mouse is on menu1 then call the function that
//opens menu2.
if (MouseOnMenu1) {
	OpenMenu2();
}
//if the mouse is on menu2 then call the function that
//opens menu3.
if (mouseOnMenu2) {
	OpenMenu3();
}
//if the mouse is on menu2 then close menu3 and open menu2.
if (mouseOnMenu1) {
	CloseMenu3();
	OpenMenu2();
}
//if the mouse is on the top text box, then close menu3
//and close menu2 and open menu1.
if(mouseOnBox) {
	CloseMenu3();
	CloseMenu2();
	OpenMenu1();
}
//this function checks to see if the mouse is clcked. If the
//mouse has been clicked it sets a variable myMouseClicked to
//true and resets the variables "mouseClicked" to false, which had been
//set from the on(press) statement in the button action scripts.
//Then, if the mouse has been clicked, it stores the selected text
//and closes the menus. Then it resets its variable "mouseClicked" to
//false for the next time it checks to see if the mouse has been clicked.

function MouseClicked() {
	with (menu1) {
		if (mouseClicked==true) {
			myMouseClicked=true;
			mouseClicked=false;
		}
	}
	with (menu2) {
		if (mouseClicked==true) {
			myMouseClicked=true;		
			mouseClicked=false;
		}
	}
	with (menu3) {
		if (mouseClicked==true) {
			myMouseClicked=true;		
			mouseClicked=false;
		}
	}
	if (myMouseClicked == true) {
		tempText = selectedText;
		CloseMenu1();
		CloseMenu2();
		CloseMenu3();
		selectedText = tempText;
		myMouseClicked = false;
	}
}
			
//this function blanks out the dynamic text boxes in menu1.
function CloseMenu1(){
	with (menu1) {
		for(i=1;i<=9;i++) {
			set ("text"+i,"");
		}
	}
}
//this function blanks out the dynamic text boxes in menu2.
function CloseMenu2(){
	with (menu2) {
		for(i=1;i<=9;i++) {
			set ("text"+i,"");
		}
	}
}
//this function blanks out the dynamic text boxes in menu3.
function CloseMenu3(){
	with (menu3) {
		for(i=1;i<=9;i++) {
			set ("text"+i,"");
		}
	}
}
//this function inserts the text for menu1. The text is
//entered into the variables c100,c200,c300...in the action
//script of frame 1. If all nine possible entries are not needed,
//then that's okay.  
function OpenMenu1() {
	with (menu1){
		text1=c[100];
		for(i=1;i<=9;i++) {
			set ("text"+i,c[i*100]);
		}
	}
}
//this function opens menu 2.
function OpenMenu2() {
	with (menu2) {
//the following statement sets the _y value of menu2.
		setProperty(menu2,_y,menu1._y+(mouseOn1ItemNumber-1)*buttonHeight);
		for(i=1;i<=9;i++) {
		set ("text"+i,c[(mouseOn1ItemNumber*100)+(i*10)]);
		}
	}
}
//this function opens menu3.
function OpenMenu3(){
	with (menu3) {
//the following statement sets the _y value of menu3.
		setProperty(menu3,_y,menu1._y+(mouseOn2ItemNumber+mouseOn1ItemNumber-2)*buttonHeight);
		for(i=1;i<=9;i++) {
		set ("text"+i,c[(mouseOn1ItemNumber*100)+(mouseOn2ItemNumber*10)+i]);
		}
	}
}
//These three functions IsMouseOnMenu1,2, and 3, test to see
//if the mouse is on the menu. It checks each button to see if the variable
//the mouseOnItem1,2,3... is set to true. This gets set to true each time the mouse
//rolls over the button and set to false every time the mouse rolls out. This is
//set in the action script of the buttons in the movieclip symbol "myMenu".
//If the text associated with each button is empty, then it does not assign the 
//mouseOnMenu to being "true. 
//These functions also assign the mouseOn1temNumber, mouseOn2ItemNumber, and 
//mouseOn3ItemNumber. These are the item numbers that the mouse is on.
function IsMouseOnMenu1() {
	with (menu1) {
		mouseOnMenu1=false;
		if (text1<>"" && mouseOnItem1==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=1;
		}
		if (text2<>"" && mouseOnItem2==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=2;
		}
		if (text3<>"" && mouseOnItem3==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=3;
		}
		if (text4<>"" && mouseOnItem4==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=4;
		}
		if (text5<>"" && mouseOnItem5==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=5;
		}
		if (text6<>"" && mouseOnItem6==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=6;
		}
		if (text7<>"" && mouseOnItem7==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=7;
		}
		if (text8<>"" && mouseOnItem8==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=8;
		}
		if (text9<>"" && mouseOnItem9==true){
			mouseOnMenu1=true;
			mouseOn1ItemNumber=9;
		}
	}
}
function IsMouseOnMenu2() {
	with (menu2) {
		mouseOnMenu2=false;
		if (text1<>"" && mouseOnItem1==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=1;
		}
		if (text2<>"" && mouseOnItem2==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=2;
		}
		if (text3<>"" && mouseOnItem3==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=3;
		}
		if (text4<>"" && mouseOnItem4==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=4;
		}
		if (text5<>"" && mouseOnItem5==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=5;
		}
		if (text6<>"" && mouseOnItem6==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=6;
		}
		if (text7<>"" && mouseOnItem7==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=7;
		}
		if (text8<>"" && mouseOnItem8==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=8;
		}
		if (text9<>"" && mouseOnItem9==true){
			mouseOnMenu2=true;
			mouseOn2ItemNumber=9;
		}
	}
}
function IsMouseOnMenu3() {
	with (menu3) {
		mouseOnMenu3=false;
		if (text1<>"" && mouseOnItem1==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=1;
		}
		if (text2<>"" && mouseOnItem2==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=2;
		}
		if (text3<>"" && mouseOnItem3==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=3;
		}
		if (text4<>"" && mouseOnItem4==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=4;
		}
		if (text5<>"" && mouseOnItem5==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=5;
		}
		if (text6<>"" && mouseOnItem6==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=6;
		}
		if (text7<>"" && mouseOnItem7==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=7;
		}
		if (text8<>"" && mouseOnItem8==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=8;
		}
		if (text9<>"" && mouseOnItem9==true){
			mouseOnMenu3=true;
			mouseOn3ItemNumber=9;
		}
	}
}
